<?php

require('fpdf/fpdf.php');

	function pdf_relatorio_promissoria($nome_usuario, $tabela ){
		//var_dump($nome_usuario);
		//var_dump($tabela);
		/*
		$pdf = new FPDF();
		$pdf->AddPage();
		$pdf->SetFont('Arial','B',16);
		$pdf->Cell(40,10,'Hello World!');
		$pdf->Output();
		*/
		
		
		$pdf = new PDF();
		// Column headings
		$header = array('Minicurso', 'Status', 'Valor');
		// Data loading
		$pdf->SetFont('Arial','',30);
		$pdf->AddPage();		   
		$pdf->Cell(40,10,'Promissoria');		   
		$pdf->SetFont('Arial','',14);
		$pdf->Ln();
		$pdf->Cell(50,50,$nome_usuario);
		$pdf->Ln(30);
		$pdf->FancyTable($header, $tabela );
		$pdf->Output();
	
	}
	
	
class PDF extends FPDF
{
	// Colored table
	function FancyTable($header, $data)
	{
		// Colors, line width and bold font
		$this->SetFillColor(255,0,0);
		$this->SetTextColor(255);
		$this->SetDrawColor(128,0,0);
		$this->SetLineWidth(.3);
		$this->SetFont('','B');
		// Header
		$w[0] = 70;	$w[1] =60;$w[2] =20;	
		for($i=0;$i<count($header);$i++)
			$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
		$this->Ln();
		// Color and font restoration
		$this->SetFillColor(224,235,255);
		$this->SetTextColor(0);
		$this->SetFont('');
		// Data
		$fill = false;
		
		$d=0;
		foreach($data as $row)
		{
			++$d;
			if($d == 1)
			$this->Cell($w[0],6,$row,'LR',0,'L',$fill);
			if($d == 2)
			$this->Cell($w[1],6,$row,'LR',0,'C',$fill);
			if($d == 3)
			$this->Cell($w[2],6,$row,'LR',0,'C',$fill);
			
			if($d == 3){
				$this->Ln();
				$d=0;
				$fill = !$fill;
			}
			
		}
		// Closing line
		$this->Cell(array_sum($w),0,'','T');

		$this->Ln(60);
		$this->Cell(90,0,'','T');
		$this->Ln();
		$this->Cell(40,10,'Athila Rocha Trindade');
	}
}
	
	//http://www.fpdf.org/
?>